package 初级算法;

/**
 * @Author cheng.song
 * @create 2021/11/9 9:43
 */
public class 删除排序数组中的重复项 {
    public static void main(String[] args) {
        int[] is = {0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(is));
    }
    public static int removeDuplicates(int[] nums) {
        int left = 0;
        for (int right = 1; right < nums.length; right++) {
            if(nums[left]!=nums[right]){
                nums[++left]=nums[right];
            }
        }
        return left+1;
    }

}


